<?php
/**
 * Created by PhpStorm.
 * User: Wenda Fang
 * Date: 14-1-4
 * Time: 下午5:54
 * Desc: admin page for the administrator
 */
session_start();

//检测是否登录，若没登录则转向登录界面
if(!isset($_SESSION['username'])){
    header("Location:signin.html");
    exit();
}


?>

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="description" content="学霸网致力于整合浩瀚繁杂的网络学习资源，以最简洁的方式呈现给大家">
    <meta name="author" content="湖北大学琴园科技创新团队">
    <link rel="shortcut icon" href="">
    <title>学霸导航--后台管理</title>

    <!-- Bootstrap -->
    <link rel="stylesheet" href="http://cdn.bootcss.com/twitter-bootstrap/3.0.3/css/bootstrap.min.css">
    <link href="jtable.2.3.1/themes/metro/blue/jtable.min.css" type="text/css" rel="stylesheet">
    <link href="css/jquery-ui.min.css" type="text/css" rel="stylesheet">
    <link href="http://cdn.bootcss.com/jquery.colorbox/1.4.33/example1/colorbox.min.css" rel="stylesheet">
    <link href="//netdna.bootstrapcdn.com/font-awesome/3.2.1/css/font-awesome.min.css" type="text/css" rel="stylesheet">
    <link rel="stylesheet" href="css/classicTheme/style.css" type="text/css" media="all" />

    <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
    <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
    <!--[if lt IE 9]>
    <script src="http://cdn.bootcss.com/html5shiv/3.7.0/html5shiv.min.js"></script>
    <script src="http://cdn.bootcss.com/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->

    <style type="text/css">
        .navbar-static-top {
            margin-bottom:20px;
        }

        i {
            font-size:18px;
        }
    </style>
</head>

<body>

<h1>学霸导航</h1><!-- Header -->
<div id="top-nav" class="navbar navbar-default navbar-static-top">
    <div class="container">
        <a class="navbar-brand" href="#"><i class="glyphicon glyphicon-user"></i> <?php echo($_SESSION['username']) ?></a>
        <a href="signout.php" class="nav navbar-nav navbar-right"><i class="glyphicon glyphicon-lock"></i> 退出登录</a>
    </div><!-- /container -->
</div>
<!-- /Header -->
<!-- Main -->
<div class="container">

    <!-- upper section -->
    <div class="row">
        <div class="col-md-2">
            <!-- left -->
            <a href="#"><strong><i class="glyphicon glyphicon-briefcase"></i> 工具箱</strong></a>
            <hr>

            <ul class="nav nav-pills nav-stacked">
                <li><a id="siteManage" href="#"><i class="glyphicon glyphicon-list-alt"></i> 网站管理</a></li>
                <li><a id="categoryManage" href="#"><i class="glyphicon glyphicon-book"></i> 类别管理</a></li>
                <li><a id="photoManage" href="get_list.php"><i class="glyphicon glyphicon-book"></i> 网站截图管理</a></li>
            </ul>

            <hr>

            <a href="#"><strong><i class="glyphicon glyphicon-time"></i> 统计报告</strong></a>

            <hr>
            <small>站点数目</small>
            <div></div>
            <small>分类数目</small>
            <div></div>

        </div><!-- /span-3 -->


        <div class="col-md-10">

            <!-- column 2 -->


            <a href="#"><strong><i class="glyphicon glyphicon-dashboard"></i> 详细信息</strong></a>

            <hr>

                <div id="details"></div>
        </div>
    </div>
</div>



<!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
<script src="http://cdn.bootcss.com/jquery/1.10.2/jquery.min.js"></script>
<!-- Include all compiled plugins (below), or include individual files as needed -->
<script src="http://cdn.bootcss.com/twitter-bootstrap/3.0.2/js/bootstrap.min.js"></script>
<script src="http://cdn.bootcss.com/jqueryui/1.10.3/jquery-ui.min.js"></script>
<script src="http://cdn.bootcss.com/jquery.colorbox/1.4.33/jquery.colorbox-min.js"></script>
<script src="http://cdn.bootcss.com/jquery.colorbox/1.4.33/i18n/jquery.colorbox-zh-CN.min.js"></script>
<script src="jtable.2.3.1/jquery.jtable.js"></script>
<script src="jtable.2.3.1/external/json2.min.js"></script>
<script src="jtable.2.3.1/localization/jquery.jtable.zh-CN.js"></script>
<script src="js/ajaxupload-min.js" type="text/javascript"></script>
<script type="text/javascript">
    $(document).ready(function () {
        $('#siteManage').click(function() {
            $('#details').empty();
            $('#details').append('<div id="sdetails"></div>');
            $('#sdetails').jtable({
                title: '详细信息',
                paging: true,
                pageSize: 10,
                sorting: true,
                defaultSorting: 'c.id',
                actions: {
                    listAction: 'sitemanage.php?action=list',
                    createAction: 'sitemanage.php?action=create',
                    updateAction: 'sitemanage.php?action=update',
                    deleteAction: 'sitemanage.php?action=delete'
                },
                fields: {
                    id: {
                        key: true,
                        create: false,
                        edit: false,
                        list: false
                    },
                    category: {
                        title: '类别',
                        width: '20%',
                        edit: false
                    },
                    name: {
                        title: '网站名称',
                        width: '20%'
                    },
                    link: {
                        title: '网址',
                        width: '10%'
                    },
                    description: {
                        title: '描述',
                        width: '30%'
                    },
                    photo: {
                        title: '首页截图',
                        width: '30%',
                        display: function (data) {
                            return '<a class="gallery cboxElement" href="' + data.record.photo + '" title="查看大图">'
                                +'<img src="' + data.record.photo + '!small" /></a>';
                        }
                    },
                    rate: {
                        title: '评分',
                        width: '10%',
                        create: false,
                        edit: false
                    }
                }
            });
            $('#sdetails').jtable('load',{},function(){
                jQuery('a.gallery').colorbox();
            });
        });

        $('#categoryManage').click(function() {
            $('#details').empty();
            $('#details').append('<div id="cdetails"></div>');
            $('#cdetails').jtable({
                title: '类别信息',
                paging: true,
                pageSize: 10,
                sorting: true,
                defaultSorting: 'name',
                actions: {
                    listAction: 'categorymanage.php?action=list',
                    createAction: 'categorymanage.php?action=create',
                    updateAction: 'categorymanage.php?action=update',
                    deleteAction: 'categorymanage.php?action=delete'
                },
                fields: {
                    id: {
                        key: true,
                        create: false,
                        edit: false,
                        list: false
                    },
                    name: {
                        title: '名称',
                        width: '20%'
                    }
                }
            });
            $('#cdetails').jtable('load');
        });
    });

</script>